const ueditor = require('koa2-ueditor')
const fs = require('fs')
module.exports = (ctx, next) => {
  let config = JSON.parse(fs.readFileSync('./config.properties', 'utf-8'))
  let newsId = (config.newsId + 1 + '').padStart(5, '0')
  return ueditor(['dist', {
    "imagePathFormat": `/upload/${newsId}/{filename}`,
    "scrawlPathFormat": `/upload/${newsId}/{filename}`,
    "snapscreenPathFormat": `/upload/${newsId}/{filename}`,
    "catcherPathFormat": `/upload/${newsId}/{filename}`,
    "videoPathFormat": `/upload/${newsId}/{filename}`,
    "filePathFormat": `/upload/${newsId}/{filename}`,
    "imageManagerListPath": `/upload/${newsId}/{filename}`,
    "fileManagerListPath": `/upload/${newsId}/{filename}`,
  }])(ctx, next)
}